﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DTO;
namespace GUI
{
    public partial class FrmTraCuuTheoLoai : Form
    {
        public FrmTraCuuTheoLoai()
        {
            InitializeComponent();
        }
        //tra cuu mon an theo loai mon an
        private void FrmTraCuuTheoLoai_Load(object sender, EventArgs e)
        {
            LoaiMonAnBUS lma = new LoaiMonAnBUS();
            List<LoaiMonAnDTO> ds = new List<LoaiMonAnDTO>();
            ds = lma.layloaimonan();
            foreach (LoaiMonAnDTO kq in ds)
            {
                comboBox1.Items.Add(kq.MaLoai + "_" + kq.TenLoai);
            }
        }
        //button tra cuu mon an theo loai
        private void bnttracuu_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == "")
            {
                MessageBox.Show("Bạn Chưa Chọn Tên Loại Món Ăn", "Thông Báo");
                return;
            }
            if (comboBox1.SelectedItem.ToString() != "")
            {
                MonAnBUS kq = new MonAnBUS();
                string str = comboBox1.SelectedItem.ToString();
                string MaLoai = str.Substring(0, str.IndexOf("_"));
                List<MonAnDTO> ds = kq.laymonan(int.Parse(MaLoai));
                GridViewdsmonan.Rows.Clear();
                for (int i = 0; i < ds.Count; i++)
                {
                    GridViewdsmonan.Rows.Add(i + 1,ds[i].MaMonAn, ds[i].TenMon ,ds[i].GiaBD, ds[i].GiaNH, ds[i].DonVi);
                }
            }
            
           

        }
        //button thoat
        private void bnthoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        //FormClosed tra cuu mon an theo loai
        private void FrmTraCuuTheoLoai_FormClosed(object sender, FormClosedEventArgs e)
        {
            Program.frm_manhinhchinh.sub_mn_tracuumontheoloai.Checked = false;
        }

        
        
    }
}
